package engineer.view.laravel.editors;

import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextArea;
import javafx.scene.text.Font;
import laravel.mvc.model.AbstractModel;

/**
 * Created by thormentor on 19-05-2014.
 */
public class ModelEditor extends TabPane {

    public ModelEditor(AbstractModel model) {
        addTab(model);
    }

    public void addTab(AbstractModel model){
        Tab tab = new Tab(model.getName());

        TextArea textArea = new TextArea();
        textArea.setFont(Font.font("Monospaced"));
        textArea.setText(model.getEntityClass().getFile().getContent());

        tab.setContent(textArea);

        getTabs().add(tab);

        if (model.getBaseModel() != null){
            addTab(model.getBaseModel());
            addTab(model.getBaseModel().getSuperModel());
        }
    }
}
